#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: Andevilin
# 功能：迷宫游戏最小格子状态的功能实现

# 定义迷宫格子的状态
U_WALL = 1
D_WALL = 4
L_WALL = 8
R_WALL = 2
ALL_WALLS = 15
FRONT = 16
VISITED = 32

class Cell(object):
    cell = None
    # 定义迷宫的格子,实现构造函数的初始化
    def __init__(self):
        self.cell = ALL_WALLS

    # 定义清除迷宫格子的状态
    def clear(self):
        self.cell = ALL_WALLS

    # 定义设置迷宫格子的状态,打破格子
    def breakWall(self, wall):
        self.cell = self.cell &  ~wall

    # 代表有墙的状态
    def hasWall(self, wall):
        if self.cell & wall == 0:
            return False
        else:
            return True

    # 代表没有墙的状态
    def noWall(self, wall):
        if self.cell & wall == 0:
            return True
        else:
            return False

    # 访问这个格子
    def visit(self):
        self.cell = self.cell | VISITED

    # 判断这个格子是否被访问过，访问过了返回True，否则返回False
    def visited(self):
        if self.cell & VISITED == 0:
            return False
        else:
            return True

    # 获取这个格子
    def getCell(self):
        return self.cell

    # 设置在前面的格子
    def setFront(self):
        self.cell = self.cell | FRONT

    # 判断这个格子是否在前面
    def isFront(self):
        if self.cell & FRONT == 0:
            return False
        else:
            return True